package cn.south.campus.admin.sys.model.vo;

import cn.south.campus.admin.sys.model.entity.SysNotice;
import cn.south.campus.common.model.vo.BaseVO;
import cn.south.campus.common.utils.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author chow
 * @since 2024/10/31
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class SysNoticeVo extends BaseVO {

    /**
     * 公告ID
     */
    private Long id;

    /**
     * 公告标题
     */
    private String noticeTitle;

    /**
     * 公告类型（1通知 2公告）
     */
    private Integer noticeType;

    /**
     * 公告内容
     */
    private String noticeContent;

    /**
     * 公告状态
     */
    private Integer status;

    public static SysNotice convert(SysNoticeVo vo) {
        SysNotice notice = new SysNotice();
        notice.setId(vo.getId());
        notice.setNoticeTitle(vo.getNoticeTitle());
        notice.setNoticeType(vo.getNoticeType());
        notice.setNoticeContent(vo.getNoticeContent());
        notice.setStatus(vo.getStatus());
        notice.setCreateTime(DateUtil.parseString(vo.getCreateTime()));
        notice.setUpdateTime(DateUtil.parseString(vo.getUpdateTime()));
        return notice;
    }

    public static SysNoticeVo convert(SysNotice notice) {
        SysNoticeVo vo = new SysNoticeVo();
        vo.setId(notice.getId());
        vo.setNoticeTitle(notice.getNoticeTitle());
        vo.setNoticeType(notice.getNoticeType());
        vo.setNoticeContent(notice.getNoticeContent());
        vo.setStatus(notice.getStatus());
        vo.setCreateTime(DateUtil.format(notice.getCreateTime()));
        vo.setUpdateTime(DateUtil.format(notice.getUpdateTime()));
        return vo;
    }
}
